<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>新建聘用合同补充合同</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>原合同信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">持证人</label>
                        <div class="layui-input-block">
                            <input type="text" id="person_name" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">人员性质</label>
                        <div class="layui-input-block">
                            <input type="text" id="person_nature" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_number" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">签约日期</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_sign_dt" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘期开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_start_dt" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘期结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_end_dt" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘用资格</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_qualification" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘用渠道</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_channel" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘费支付方式</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_pay_type" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘费</label>
                        <div class="layui-input-block">
                            <input type="text" id="yuan_money" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>




            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>补充合同信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>补充合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">签订日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="sign_dt" id="sign_dt" placeholder="请选择" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">聘用说明</label>
                        <div class="layui-input-block">
                            <textarea id="yongshuo" name="yongshuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label" id="money_label"><text>*</text>补充聘费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入" name="money" id="money" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">聘费支付方式</label>
                        <div class="layui-input-block">
                            <input type="text" id="pay_type_name" name="pay_type_name" readonly placeholder="请输入" clearable autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">聘费说明</label>
                        <div class="layui-input-block">
                            <textarea id="feishuo" name="feishuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘期开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="startdt" id="startdt" placeholder="请输入" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>聘期结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt" id="enddt" placeholder="请输入" clearable autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    var param_mid = getQueryVariable('mid');

    $("#commentForm").validate({
        rules: {
            number: {required: true},
            money: {required: true},
            startdt: {required: true},
            enddt: {required: true},
        },
        messages:{
            number: {required: "请输入"},
            money: {required: "请输入"},
            startdt: {required: "请选择"},
            enddt: {required: "请选择"},
        }
    });


    layui.use(['laytp', 'form'], function() {
        var form = layui.form;

        render_input_attr();

        facade.ajax({type: 'get', url: ask_cert_empbu_add,data:{mid:param_mid}}).done(function(res){
            if (res.code === 2000) {
                var midinfo = res.data.midinfo;

                $("#person_name").val(midinfo.person_name);
                $("#person_nature").val(midinfo.person_nature);
                $("#yuan_number").val(midinfo.number);
                $("#yuan_sign_dt").val(midinfo.sign_dt);
                $("#yuan_start_dt").val(midinfo.start_dt);
                $("#yuan_end_dt").val(midinfo.end_dt);
                $("#yuan_qualification").val(midinfo.qualification);
                $("#yuan_channel").val(midinfo.channel);
                $("#yuan_pay_type").val(midinfo.pay_type);
                $("#yuan_money").val(midinfo.money);


                $("#pay_type_name").val(midinfo.pay_type);



                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });

        form.on('submit(add)', function(data){

            var validRes = $("#commentForm").valid();

            var yuan_start_dt = $("#yuan_start_dt").val();
            var yuan_end_dt = $("#yuan_end_dt").val();

            if(data.field.startdt < yuan_start_dt){
                facade.error("聘期开始时间不能小于原合同的聘期开始时间");
                validRes = false;
            }

            if(data.field.enddt > yuan_end_dt){
                facade.error("聘期结束时间不能大于原合同的聘期结束时间");
                validRes = false;
            }

            if(!validRes){return false;}

            data.field.mid = param_mid;
            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            facade.ajax({url: ask_cert_empbu_add, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });
    });
</script>
</body>
</html>
